package com.ima.web.beans.db;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

@Entity
@Table(name="categories")
public class Categories {
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name="categories_id")
	private Integer categoriesId;
	
	@Column(name="name")
	private String name;
	
	@Column(name="description")
	private String description;
	
	@Column(name="approved")
	private Boolean approved;
	
	@ManyToOne
	@JoinColumn(name="approved_by_userid")
	private Users approver;
	
	@Column(name="approved_date")
	private Date approvedDate;
	
	@ManyToOne
	@JoinColumn(name="requested_by_userid")
	private Users requester;
	
	@Column(name="requested_date")
	private Date requestedDate;
	
	@Column(name="created_date")
	private Date createdDate;
	
	@Column(name="updated_date")
	private Date updatedDate;
	
	@Column(name="deleted")
	private Boolean deleted;
	
	@Fetch(FetchMode.SUBSELECT)
	@OneToMany(mappedBy="category",fetch=FetchType.EAGER)
	private List<SubCategories> subCategories;

	//Init default values
	public Categories(){
		deleted = false;
		approved = false;
	}
	
	public Boolean getApproved() {
		return approved;
	}

	public void setApproved(Boolean approved) {
		this.approved = approved;
	}

	public Users getRequester() {
		return requester;
	}
	
	public void setRequester(Users requester) {
		this.requester = requester;
	}
	
	public Date getRequestedDate() {
		return requestedDate;
	}

	public void setRequestedDate(Date requestedDate) {
		this.requestedDate = requestedDate;
	}

	public Integer getCategoriesId() {
		return categoriesId;
	}

	public void setCategoriesId(Integer categoriesId) {
		this.categoriesId = categoriesId;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Date getCreatedDate() {
		return createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}

	public Date getUpdatedDate() {
		return updatedDate;
	}

	public void setUpdatedDate(Date updatedDate) {
		this.updatedDate = updatedDate;
	}

	public Users getApprover() {
		return approver;
	}

	public void setApprover(Users approver) {
		this.approver = approver;
	}

	public Date getApprovedDate() {
		return approvedDate;
	}

	public void setApprovedDate(Date approvedDate) {
		this.approvedDate = approvedDate;
	}

	public Boolean getDeleted() {
		return deleted;
	}

	public void setDeleted(Boolean deleted) {
		this.deleted = deleted;
	}

	public List<SubCategories> getSubCategories() {
		return subCategories;
	}

	public void setSubCategories(List<SubCategories> subCategories) {
		this.subCategories = subCategories;
	}
	
	
}
